<div class="col-sm-3">
<?php 
if(isset($banner_left) && $banner_left->num_rows() > 0):
  $i = 1;
  $widget = 1;
  $num_rows = $banner_left->num_rows();

  foreach($banner_left->result_array() as $row):
    $mod = $i % IMAGE_SLIDE_BANNER_NUM;
?>
<?php if($mod === 1): ?>
  <!-- Active Theme Color Widget with Carousel -->
  <div class="widget m-b">
    <div class="widget-extra-full themed-background-dark">
      <!-- Carousel -->
      <div id="widget-carousel-ads-left<?php echo $widget; ?>" class="carousel auto slide remove-margin">
        <!-- Wrapper for slides -->
        <div class="carousel-inner"> 
<?php endif; ?>

          <div class="item <?php echo $mod === 1 ? ' active' : ''; ?>">
            <a href="<?php echo $row[field('url')]; ?>">
              <img src="<?php echo base_url(UPLOAD_PATH.'banners/'.$row[field('image')]); ?>" alt="" title="<?php echo $row[field('name')] ?>">
            </a>
          </div>

<?php if($mod === 0 || $i == $num_rows): ?>
        </div>
        <!-- END Wrapper for slides -->

        <!-- Controls -->
        <a class="left carousel-control" href="#widget-carousel-ads-left<?php echo $widget; ?>" data-slide="prev">
          <span><i class="fa fa-chevron-left"></i></span>
        </a>
        <a class="right carousel-control" href="#widget-carousel-ads-left<?php echo $widget; ?>" data-slide="next">
          <span><i class="fa fa-chevron-right"></i></span>
        </a>
        <!-- END Controls -->
      </div>
      <!-- END Carousel -->
    </div>
  </div>
  <!-- END Active Theme Color Widget with Carousel -->
  <?php $widget++; ?>
<?php endif; ?>

<?php 
    $i++;
  endforeach;
endif;
?>
</div>
